package com.neusoft.elmboot.util;

import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author chj
 * @date 2024年9月7日
 */
public class MD5Lock {
	/**
	 * MD5加密工具
	 */
	public static String getMD5Str(String val) throws NoSuchAlgorithmException {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		return Base64.encodeBase64String(md5.digest((val + Constant.SALT).getBytes()));
	}

	public static void main(String[] args) {
		try {
			System.out.println(getMD5Str("yang" + Constant.SALT));
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
	}

}
